Skip to content

MINIFICPP-2798 Mock library for C extensions#2170

Open
martinzink wants to merge 3 commits intoc_api_devfrom
MINIFICPP-2798
Open

MINIFICPP-2798 Mock library for C extensions#2170
martinzink wants to merge 3 commits intoc_api_devfrom
MINIFICPP-2798

Conversation

@martinzink
Copy link
Copy Markdown
Member

@martinzink martinzink commented May 5, 2026

Depends on

Separates the CPP wrapper into a abstract interface and the Cffi layer (that commincates via the stable API), and also introduces a Mock alternative implementation, with its easier to create new unit tests that only test the processors controllers services business logic without the need to depend on the libminifi library.


Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file?
  • If applicable, have you updated the NOTICE file?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.

@martinzink martinzink requested a review from Copilot May 5, 2026 14:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a C++ mock library intended to support testing/verification of C extensions, and refactors the C++ extension wrapper layer to rely on abstract ProcessContext / ProcessSession interfaces with concrete CFFI-backed implementations.

Changes:

  • Refactor extension wrapper APIs (ProcessContext, ProcessSession, Logger) to use abstract base classes and CFFI-backed concrete implementations (Cffi*).
  • Add a new mocklib (mock process context/session/logger + stubbed C API symbols) for extension testing without a full agent runtime.
  • Extend/adjust C API utility helpers (minifiStringView, conversions) and add new small common utilities (regex wrapper + attribute error category).

Reviewed changes

Copilot reviewed 24 out of 28 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
libminifi/test/integration/extension-verification-test/CApiExtension.cpp Updates extension metadata string-view helper usage.
extensions/llamacpp/processors/RunLlamaCppInference.cpp Adjusts property access to updated ProcessContext API.
extensions/llamacpp/processors/ExtensionInitializer.cpp Updates extension metadata string-view helper usage.
extension-framework/cpp-extension-lib/src/core/ProcessSession.cpp Implements CFFI-backed ProcessSession operations + new session APIs.
extension-framework/cpp-extension-lib/src/core/ProcessContext.cpp Implements CFFI-backed ProcessContext operations + dynamic props/SSL data.
extension-framework/cpp-extension-lib/src/core/logging/Logger.cpp Renames/implements CFFI-backed logger wrapper.
extension-framework/cpp-extension-lib/src/core/ControllerServiceContext.cpp Updates controller service property lookup string-view helper usage.
extension-framework/cpp-extension-lib/mocklib/src/MockProcessSession.cpp Adds mock session implementation for tests (flow file lifecycle, content, attributes).
extension-framework/cpp-extension-lib/mocklib/src/MockProcessContext.cpp Adds mock context implementation for tests (properties, defaults).
extension-framework/cpp-extension-lib/mocklib/src/mock-minifi-c.cpp Adds stubbed C API symbol definitions for mock/test linkage.
extension-framework/cpp-extension-lib/mocklib/include/MockUtils.h Adds small helpers for building mock processor metadata/logger.
extension-framework/cpp-extension-lib/mocklib/include/MockStreams.h Adds in-memory mock InputStream/OutputStream implementations.
extension-framework/cpp-extension-lib/mocklib/include/MockProcessSession.h Declares mock session class and mock flow file data model.
extension-framework/cpp-extension-lib/mocklib/include/MockProcessContext.h Declares mock process context class.
extension-framework/cpp-extension-lib/mocklib/include/MockLogger.h Adds a test logger capturing log strings by level.
extension-framework/cpp-extension-lib/mocklib/CMakeLists.txt Adds build target for the new mock library.
extension-framework/cpp-extension-lib/include/api/utils/Ssl.h Introduces SSL data structs for the extension API surface.
extension-framework/cpp-extension-lib/include/api/utils/ProcessorConfigUtils.h Updates property parsing helpers to use the new getProperty(PropertyReference, FlowFile*) API.
extension-framework/cpp-extension-lib/include/api/utils/minifi-c-utils.h Introduces minifiStringView + adds conversions from MinifiStringView.
extension-framework/cpp-extension-lib/include/api/core/Resource.h Updates registration helpers to use CFFI wrappers + adds variadic registration helpers.
extension-framework/cpp-extension-lib/include/api/core/ProcessSession.h Refactors ProcessSession into abstract interface + adds CffiProcessSession.
extension-framework/cpp-extension-lib/include/api/core/ProcessContext.h Refactors ProcessContext into abstract interface + adds CffiProcessContext and new APIs.
extension-framework/cpp-extension-lib/include/api/core/logging/Logger.h Renames wrapper to CffiLogger.
extension-framework/cpp-extension-lib/CMakeLists.txt Adds mocklib subdirectory to build.
core-framework/common/src/utils/RegexUtils.cpp Adds regex implementation backing new RegexUtils header.
core-framework/common/src/utils/AttributeErrors.cpp Adds attribute error category implementation.
core-framework/common/include/utils/RegexUtils.h Adds regex wrapper interface and libstdc++ workaround.
core-framework/common/include/utils/AttributeErrors.h Adds attribute error code/category declarations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread extension-framework/cpp-extension-lib/mocklib/src/mock-minifi-c.cpp Outdated
Comment thread extension-framework/cpp-extension-lib/mocklib/src/mock-minifi-c.cpp Outdated
Comment thread extension-framework/cpp-extension-lib/mocklib/include/MockProcessSession.h Outdated
Comment thread extension-framework/cpp-extension-lib/mocklib/include/MockLogger.h Outdated
Comment thread extension-framework/cpp-extension-lib/mocklib/include/MockStreams.h
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@martinzink martinzink marked this pull request as ready for review May 6, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants